/**
 * Copyright © 2020 易久批信息技术有限公司. All rights reserved.
 */
package com.dysm.observer;

/**
 * 观察者模式
 * @author xiay
 * @since 2020/12/17 2:08 下午
 */
public class ObserverClient {

    public static void main(String[] args) {
        SubjectImpl subject = new SubjectImpl();

        ObserverImpl observer1 = new ObserverImpl();
        ObserverImpl observer2 = new ObserverImpl();
        ObserverImpl observer3 = new ObserverImpl();
        subject.register(observer1);
        subject.register(observer2);
        subject.register(observer3);

        subject.setState(1);
        System.out.println(observer1.getMyState());
        System.out.println(observer2.getMyState());
        System.out.println(observer3.getMyState());

    }
}
